'use strict';

const Controller = require('egg').Controller;

class UserController extends Controller {
    //登录
    async login() {
        let {ctx,service} = this;
        let {username,password} = ctx.request.body;
        console.log(username,password)
        if(username && password){
            let target = await service.user.login(username,password);
            if(target.length){
                ctx.body = {
                    code:1,
                    msg:'登录成功'
                }
            }else{
                ctx.body = {
                    code:0,
                    msg:'登录失败'
                }
            }
        }else{
            ctx.body = {
                code:2,
                msg:'参数错误'
            }
        }
    }
}

module.exports = UserController;
